﻿namespace Jim.K3Cloud;

/// <summary>
/// 获取字段功能控制信息
/// </summary>
[Sdk("Kingdee.BOS.ServiceFacade.ServicesStub.Metadata.MetadataService.GetFieldFuncControlInfos", "获取字段功能控制信息")]
public class K3CloudBuildFilterSQLRequest : ISdkRequest<K3CloudBuildFilterSQLResponse>
{
    /// <summary>
    /// 过滤条件对象
    /// </summary>
    public K3CloudFilterObject filterObj { get; set; }
    /// <summary>
    /// 是否返回SQL
    /// </summary>
    public bool returnSQL { get; set; }

    public bool ignoreBlandValue { get; set; }

    public void Validate()
    {
    }
}

/// <summary>高级过滤条件对象：可供选择的过滤字段列表，已选择的过滤条件行信息</summary>
[Serializable]
public class K3CloudFilterObject
{

    /// <summary>过滤条件表格元数据</summary>
    public FilterGridAppearance FilterGridAppearance { get; set; }

    /// <summary>可供选择的过滤字段列表</summary>
    public List<K3CloudFilterField> FilterFieldList { get; set; }

    /// <summary>全部字段列表；包括未选择的实体字段</summary>
    public List<K3CloudFilterField> AllFilterFieldList { get; set; }

    /// <summary>用户已经设置的过滤条件行</summary>
    public List<K3CloudFilterRow> FilterRows { get; set; }

    /// <summary>高级设置的过滤条件行</summary>
    public List<K3CloudFilterRow> AdvancedFilterRows { get; set; }

    /// <summary>过滤条件元数据 ，包含比较符、逻辑、排序方式</summary>
    public K3CloudFilterMetaData FilterMetaData { get; set; }

    /// <summary>用户配置的过滤条件，以字符串格式设置、输出</summary>
    public string Setting { get; set; }

    /// <summary>是否支持特殊字符查询</summary>
    public bool SpecialCharQueryEnabled { get; set; }

    /// <summary>是否支持多关键字的模糊查询，空格作为条件分隔符</summary>
    public bool BlankSplitQueryEnabled { get; set; }

    /// <summary>Oracle忽略大小写（目前只用于查询时加在用户自己定义插件）</summary>
    public bool IgnoreOracleNLSCOMP { get; set; }

    /// <summary>元数据</summary>
    public K3CloudBusinessInfo BusinessInfo { get; set; }

    /// <summary>自定义异常信息，好定位在哪里解析公式时出错</summary>
    public string ExceptionMsg { get; set; }


}

/// <summary>高级过滤条件包含的元数据：逻辑比较符，比较符、排序类型</summary>
[Serializable]
public class K3CloudFilterMetaData
{
    /// <summary>可选比较符号集合</summary>
    public List<K3CloudCompareType> CompareTypes { get; set; }

    /// <summary>可选排序方式集合</summary>
    public List<K3CloudEnu_SortType> SortTypes { get; set; }

    /// <summary>可选逻辑比较符集合</summary>
    public List<K3CloudLogicOperate> Logics { get; set; }

    /// <summary>版本</summary>
    public string Version { get; private set; }

    public string Marks { get; set; }

    public string NullMarks { get; set; }

    public string NullMarksExt { get; set; }

    public bool IsConditionFilter { get; set; }
}


/// <summary>过滤条件行</summary>
public class K3CloudFilterRow
{
    /// <summary>左括号</summary>
    public string LeftBracket { get; set; }

    /// <summary>当前选中的字段名</summary>
    public K3CloudFilterField FilterField { get; set; }

    /// <summary>当前选中的比较符</summary>
    public K3CloudCompareType CompareType { get; set; }

    /// <summary>当前选中（设置）的比较值</summary>
    public string Value { get; }

    /// <summary>右括号</summary>
    public string RightBracket { get; set; }

    /// <summary>比较逻辑</summary>
    public K3CloudLogicOperate Logic { get; set; }

    /// <summary>行号</summary>
    public int RowIndex { get; set; }

    /// <summary>字段标签</summary>
    public string FieldCaption { get; set; }
}



/// <summary>高级过滤页签包含的可选择的过滤字段</summary>
[Serializable]
public class K3CloudFilterField
{

    /// <summary>字段标题</summary>
    public LocaleValue Caption { get; set; }

    /// <summary>字段名称（唯一标识）,存储KEY值</summary>
    public string FieldName { get; set; }

    /// <summary>字段所在实体；存储实体Key值；报表等可以为空；客户端在分录改变时，据此值甄选出可选的字段列表</summary>
    public string EntityKey { get; set; }

    /// <summary>实体名称</summary>
    public LocaleValue EntityCaption { get; set; }

    /// <summary>字段使用的比较符; 客户端据此检索出可用的比较符号集合</summary>
    public string CompareGroupID { get; set; }

    /// <summary>字段使用的比较符集合（通过CompareGroupID 获取）</summary>
    public List<K3CloudCompareType> CompareType { get; set; }

    /// <summary>默认过滤比较符; 客户端据此检索出默认的比较符号</summary>
    public string DefaultCompareID { get; set; }

    /// <summary>字段类型</summary>
    public K3CloudSqlStorageType FieldType { get; set; }

    /// <summary>数据库存储类型</summary>
    public int DatabaseType { get; set; }

    /// <summary>对应的元素类型id; 客户端控件通过枚举此值,确定每个字段的比较值录入控件类型</summary>
    public int ElementTypeID { get; set; }

    /// <summary>快捷过滤的元素类型id; 快捷面板上的客户端控件通过枚举此值,确定每个字段的比较值录入控件类型</summary>
    public int QuickFilterElementTypeID { get; set; }

    /// <summary>字段显示顺序</summary>
    public int Seq { get; set; }

    /// <summary>子字段显示顺序（如弹性域字段）</summary>
    public int SubFieldSeq { get; set; }

    public JObject Editor { get; set; }

    /// <summary>快捷过滤面板上使用的控件</summary>
    public JObject QuickFilterEditor { get; set; }

    public bool IsFlexSubField { get; set; }

    /// <summary>父字段</summary>
    public string FlexParentFieldKey { get; set; }

    public string Key { get; set; }
}



/// <summary>过滤条件界面的比较符</summary>
[Serializable]
public class K3CloudCompareType
{
    /// <summary>比较符号编码</summary>
    public string Id { get; set; }

    /// <summary>名称</summary>
    public string Name { get; set; }

    /// <summary>比较符号</summary>
    public string Operate { get; set; }

    /// <summary>输入控件类型</summary>
    public int InputCtlType { get; set; }

    /// <summary>下拉列表数据源</summary>
    public int DataSourceType { get; set; }

    /// <summary>是否必须录入</summary>
    public bool NeedInput { get; set; }

    /// <summary>下拉列表，按Caption比较还是按Value比较；可废弃(Johnny Ding)</summary>
    public int DataFieldIndex { get; set; }

    /// <summary>比较符号集合编码</summary>
    public int GroupID { get; set; }

    /// <summary>比较值</summary>
    public string Value { get; set; }

    /// <summary>顺序</summary>
    public object Seq { get; set; }

    /// <summary>插件</summary>
    public string ClassName { get; set; }
}


/// <summary>过滤条件控件，包含可选实体与条件表格两部分</summary>
[Serializable]
public class FilterGridAppearance : K3CloudAppearance
{
    /// <summary>文本默认对齐方式</summary>
    public const int TEXTALIGN_DEFAULT = 0;
    /// <summary>文本对齐方式_左对齐</summary>
    public const int TEXTALIGN_LEFT = 1;
    /// <summary>文本对齐方式_居中对齐</summary>
    public const int TEXTALIGN_CENTER = 3;
    /// <summary>文本对齐方式_右对齐</summary>
    public const int TEXTALIGN_RIGHT = 2;
    /// <summary>锁定性_新增锁定</summary>
    public const int LOCK_NEW = 1;
    /// <summary>锁定性_修改锁定</summary>
    public const int LOCK_EDIT = 2;
    /// <summary>锁定性_审核后锁定</summary>
    public const int LOCK_AUTIDING = 4;
    /// <summary>锁定性_过滤方案的显示隐藏列中的显示单元格锁定</summary>
    public const int LOCK_FILTERSHOWHIDE = 8;
    internal const string FS_DISABLED = "disabled";
    internal const string FS_VISIBLE = "visible";
    /// <summary>属性名 : 小数精度</summary>
    internal const string FS_PRECISION = "decimalPrecision";
    /// <summary>金额或单价币别符号格式</summary>
    internal const string FS_NUMFMTINFO = "NumFmtInfo";

    public List<K3CloudFilterGridField> FieldList { get; set; }

    /// <summary>元素类型</summary>
    [DefaultValue(1029)]
    public int ElementType { get; set; }

}


/// <summary>过滤条件表格过滤字段元数据</summary>
public class K3CloudFilterGridField
{
    /// <summary>编码</summary>
    public virtual string Id { get; set; }

    /// <summary>字段逻辑</summary>
    public K3CloudField Field { get; set; }

    /// <summary>字段外观</summary>
    public K3CloudFieldAppearance FieldAppearance { get; set; }
}




/// <summary>通用控件外观基类</summary>
[Serializable]
public class ControlAppearance : K3CloudAppearance
{
    /// <summary>文本默认对齐方式</summary>
    public const int TEXTALIGN_DEFAULT = 0;
    /// <summary>文本对齐方式_左对齐</summary>
    public const int TEXTALIGN_LEFT = 1;
    /// <summary>文本对齐方式_居中对齐</summary>
    public const int TEXTALIGN_CENTER = 3;
    /// <summary>文本对齐方式_右对齐</summary>
    public const int TEXTALIGN_RIGHT = 2;
    /// <summary>锁定性_新增锁定</summary>
    public const int LOCK_NEW = 1;
    /// <summary>锁定性_修改锁定</summary>
    public const int LOCK_EDIT = 2;
    /// <summary>锁定性_审核后锁定</summary>
    public const int LOCK_AUTIDING = 4;
    /// <summary>锁定性_过滤方案的显示隐藏列中的显示单元格锁定</summary>
    public const int LOCK_FILTERSHOWHIDE = 8;
    internal const string FS_DISABLED = "disabled";
    internal const string FS_VISIBLE = "visible";
    /// <summary>属性名 : 小数精度</summary>
    internal const string FS_PRECISION = "decimalPrecision";
    /// <summary>金额或单价币别符号格式</summary>
    internal const string FS_NUMFMTINFO = "NumFmtInfo";
    /// <summary>锁定默认值，都没有锁定</summary>
    public const int DfLocked = 0;

    /// <summary>风格/线条</summary>
    public virtual int Style { get; set; }

    /// <summary>对齐方式</summary>
    public int TextAlign { get; set; }

    /// <summary>标题对齐方式</summary>
    public int TitleAlign { get; set; }

    public string ToolTip { get; set; }

    /// <summary>对齐方式</summary>
    public int DefaultTextAlign { get; set; }

    /// <summary>是否显示标题</summary>
    public int ShowTitle { get; set; }

    /// <summary>是否显示菜单</summary>
    public int ShowMenu { get; set; }

    /// <summary>是否停靠</summary>
    public virtual int Dock { get; set; }


    /// <summary>横向滚动条</summary>
    public int Hscroll { get; set; }

    /// <summary>纵向滚动条</summary>
    public int Vscroll { get; set; }

    /// <summary>外边距</summary>
    public virtual string Margin { get; set; }

    /// <summary>内边距</summary>
    public string Padding { get; set; }

    /// <summary>边框宽度</summary>
    public string BorderWidth { get; set; }

    /// <summary>边框颜色</summary>
    public string BorderColor { get; set; }

    /// <summary>背景颜色</summary>
    public string BackColor { get; set; }

    /// <summary>前景颜色</summary>
    public string TextColor { get; set; }


    /// <summary>所在分录标示</summary>
    [DefaultValue("FBillHead")]
    public string EntityKey { get; set; }

    /// <summary>
    /// 返回/设置 此控件的上级控制控件
    /// 业务场景举例：
    /// 当过滤条件区域选择的单据体改变的时候，需要动态刷新过滤表格中的过滤字段；
    /// </summary>
    public virtual string ControlKey { get; set; }


    /// <summary>所在容器标示</summary>
    [DefaultValue(null)]
    public string Container { get; set; }

    /// <summary>显示层次</summary>
    public int ZOrderIndex { get; set; }

    /// <summary>输入顺序</summary>
    public int Tabindex { get; set; }

    /// <summary>字体名称</summary>
    public string Font { get; set; }

    /// <summary>是否折行</summary>
    public virtual bool LineWrap { get; set; }

    /// <summary>是否允许设置高度</summary>
    [DefaultValue(true)]
    public virtual bool AutoHeight { get; set; }

    /// <summary>移动业务自动高度，根据内容控制</summary>
    [DefaultValue(false)]
    public bool MobileAutoHeight { get; set; }

    /// <summary>绑定的表单服务类别(业务对象、分录、控件等等)</summary>
    public int BusinessServiceType { get; set; }


    /// <summary>
    /// 锁定性；
    /// 由于前期设计会存在如下问题：
    /// （1）如果以前锁定性的值是－1，计算后没问题；
    /// （2）如果是某个值，如1+2+4+16，有问题了，因为以后再加的值不存在这个值中；（领域绝大部分都这样）；
    /// （3）如果是2147483647也没问题；
    /// 鉴于以上原因，另外再设计一个锁定性字段LockedExt；
    /// 其类型为string，格式11101101111的形式；1表示锁定，0表示不锁定；
    /// 其判断逻辑详见GetLockedExtValue(BOSEnums.Enu_LockedExtIndex locked)；
    /// 本属性的占位记录，如果新增了一项，请在枚举Enu_LockedExtIndex中补充；
    /// </summary>
    [DefaultValue("")]
    public virtual string LockedExt { get; set; }
}

/// <summary>字段外观基类</summary>
[Serializable]
public class K3CloudFieldAppearance : ControlAppearance
{
    /// <summary>Josn对象节点标示_值</summary>
    public const string FS_VALUE = "value";
    /// <summary>Josn对象节点标示_编辑值</summary>
    public const string FS_NUMBER = "number";
    /// <summary>Josn对象节点标示_显示值</summary>
    public const string FS_NAME = "name";
    public const string FS_KEY = "key";
    public const string FS_MKVAL = "MkVal";
    /// <summary>是否脱敏</summary>
    public const string FS_ISMK = "IsMk";
    /// <summary>脱敏数据显示方式; 0显示脱敏数据(显示小眼睛); 1显示真实数据; 2显示脱敏数据(不显示小眼睛)</summary>
    public const string FS_MKMODEL = "MkModel";
    /// <summary>弹性域子列，子列的key为$${field.key}__{subfield.key}</summary>
    public bool IsFlexSubField { get; private set; }

    public string Key { get; private set; }

    /// <summary>对应的业务元数据类</summary>
    public virtual K3CloudField Field { get; set; }

    /// <summary>标签颜色</summary>
    public string LabelColor { get; set; }

    /// <summary>隐藏批量选择框</summary>
    public bool HideBatchCheck { get; set; }

    /// <summary>外框颜色</summary>
    public string FrameBorderColor { get; set; }

    /// <summary>字段在叙事簿中是否显示为超链接</summary>
    [DefaultValue(false)]
    public bool IsHyperlink { get; set; }

    /// <summary>BOSF7字段的标题增加动态属性支持不显示标题下划线热链模式;</summary>
    [DefaultValue(true)]
    public bool LableHyperlink { get; set; }

    /// <summary>是否审核可见</summary>
    /// <returns></returns>
    public bool IsAuditVisible() => (this.Visible & 16) == 16;

    /// <summary>是否序时簿可见;如果为False，则本字段不可能出现在可选显示隐藏字段列表中；</summary>
    /// <returns></returns>
    public bool IsListVisible() => (this.Visible & 2) == 2;

    /// <summary>F8 是否可见 ，False不可见 Weiling_tian Edit 2012-3-7 ；</summary>
    /// <returns></returns>
    public bool IsListBaseVisible() => (this.Visible & 65536) == 65536;

    /// <summary>是否过滤可见；字段是否允许参与过滤，即能否出现在过滤条件列表中</summary>
    /// <returns></returns>
    public bool IsFilterVisible() => (this.Visible & 256) == 256;

    /// <summary>是否排序可见；自窜是否允许参与排序，即出现在排序列表中</summary>
    /// <returns></returns>
    public bool IsSortVisible() => (this.Visible & 512) == 512;

    /// <summary>是否快速查询可见</summary>
    /// <returns></returns>
    public bool IsQKQueryVisible() => (this.Visible & 8192) == 8192;

    /// <summary>是否套打可见</summary>
    /// <returns></returns>
    public bool IsPrintVisible() => (this.Visible & 4096) == 4096;

    /// <summary>是否移动商务可见</summary>
    /// <returns></returns>
    public bool IsMobileBusiVisible() => (this.Visible & 2048) == 2048;

    /// <summary>是否发布到工作流事件</summary>
    /// <returns></returns>
    public bool IsIssueEvent() => (this.Visible & 16384) == 16384;

    /// <summary>是否发布到叙事簿链接</summary>
    /// <returns></returns>
    public bool IsListLink() => (this.Visible & 32768) == 32768;

    /// <summary>是否审核锁定</summary>
    /// <returns></returns>
    public bool IsAuditLock() => (this.Locked & 4) == 4;

    /// <summary>是否新增锁定</summary>
    /// <returns></returns>
    public bool IsNewLock() => (this.Locked & 1) == 1;

    /// <summary>是否修改锁定</summary>
    /// <returns></returns>
    public bool IsModifyLock() => (this.Locked & 2) == 2;

    /// <summary>序时簿默认显示顺序</summary>
    public int ListTabIndex { get; set; }

    /// <summary>字段掩码</summary>
    public string Mask { get; set; }

    /// <summary>显示格式化字符串</summary>
    public string DisplayFormatString { get; set; }

    /// <summary>显示编辑按钮</summary>
    public virtual bool ShowEditButton { get; set; }

    /// <summary>显示梯增/减按钮</summary>
    public bool ShowSpinButton { get; set; }

    /// <summary>
    /// 添加编辑风格，
    /// 0：标准，字段或点击按钮编辑，
    /// 1：禁止编辑
    /// 2：仅点击按钮编辑，
    /// </summary>
    public int TextEditStyle { get; set; }

    /// <summary>
    /// 列表列显示控件
    /// 0：标准，不可编辑，
    /// 1：链接
    /// 2：按钮，
    /// 3：图片，
    /// 4：html文本
    /// </summary>
    public int ListColumnStyle { get; set; }

    /// <summary>列表单元格支持提示</summary>
    public int ListColumnDspTips { get; set; }

    /// <summary>列表列显示控件应用到单据</summary>
    public int BlAppLstColStyle { get; set; }

    /// <summary>列表默认显示宽度</summary>
    /// <returns></returns>
    public virtual LocaleValue ListDefaultWidth { get; set; }

    /// <summary>对应在表格中列的索引</summary>
    public int ColIndex { get; set; }

}

public class K3CloudAppearance
{
    /// <summary>
    /// That all visible;
    /// Composition:
    /// 1+2+4+8+16+32+64+128+256+512+1024+2048+4096+8192+16384+32768+65536+131072
    /// +262144+524288+1048576+2097152+4194304+8388608+16777216+33554432+67108864
    /// +134217728+268435456+536870912+1073741824
    /// </summary>
    public const int DfVisible = 2147483647;
    /// <summary>可见性_单据上可见</summary>
    public const int VIS_BILL = 1;
    /// <summary>可见性_序时簿上可见</summary>
    public const int VIS_LIST = 2;
    /// <summary>可见性_设计状态可见</summary>
    public const int VIS_NOVIS_DESIGN = 4;
    /// <summary>可见性_仅设计可见??</summary>
    public const int VIS_ONLYDESIGNPOPERTY = 8;
    /// <summary>可见性_审核后可见</summary>
    public const int VIS_AUTIDING = 16;
    /// <summary>可见性_单据查看可见</summary>
    public const int VIS_VIEW = 32;
    /// <summary>可见性_单据新增可见</summary>
    public const int VIS_NEW = 64;
    /// <summary>可见性_单据维护可见</summary>
    public const int VIS_EDIT = 128;
    /// <summary>可见性_过滤条件字段列表可见</summary>
    public const int VIS_FILTER = 256;
    /// <summary>可见性_在排序列表可见</summary>
    public const int VIS_SORT = 512;
    /// <summary>可见性_默认显示 (显示隐藏列是否勾选)</summary>
    public const int VIS_DEFAULT = 1024;
    /// <summary>可见性_移动商务可见性</summary>
    public const int VIS_MOBILEBUSINESS = 2048;
    /// <summary>可见性_套打可见性</summary>
    public const int VIS_PRINT = 4096;
    /// <summary>可见性_快速查询可见性</summary>
    public const int VIS_QKQUERY = 8192;
    /// <summary>可见性_是否发布工作流事件</summary>
    public const int VIS_EVENT = 16384;
    /// <summary>可见性_是否发布叙事簿链接</summary>
    public const int VIS_LISTLINK = 32768;
    /// <summary>可见性_F8列表</summary>
    public const int VIS_LISTF8 = 65536;
    /// <summary>业务对象元素默认标示；用于LayoutInfo中，把业务对象整体属性和分录区分开</summary>
    public const string FORM_KEY = "_BILL";
    /// <summary>单据体元素默认标示；用于LayoutInfo中，把单据头和其他分录区分开</summary>
    public const string BILL_HEAD = "FBillHead";

    /// <summary>是否设计时调用</summary>
    public bool Design { get; set; }

    /// <summary>左</summary>
    public virtual LocaleValue Left { get; set; }

    /// <summary>上</summary>
    public virtual LocaleValue Top { get; set; }

    /// <summary>高</summary>
    public virtual LocaleValue Height { get; set; }


    /// <summary>标题宽度</summary>
    public LocaleValue LabelWidth { get; set; }

    /// <summary>宽</summary>
    public virtual LocaleValue Width { get; set; }

    /// <summary>可见性</summary>
    [DefaultValue(2147483647)]
    public virtual int Visible { get; set; }

    /// <summary>
    /// 可见性；
    /// 由于前期设计会存在如下问题：
    /// （1）如果以前可见性的值是－1，计算后没问题；
    /// （2）如果是某个值，如1+2+4+16，有问题了，因为以后再加的值不存在这个值中；（领域绝大部分都这样）；
    /// （3）如果是2147483647也没问题；
    /// 鉴于以上原因，另外再设计一个可见性字段VisibleExt；
    /// 其类型为string，格式11101101111的形式；1表示可见，0表示不可见；
    /// 其判断逻辑详见GetVisibleExtValue(BOSEnums.Enu_VisibleExtIndex visible)；
    /// 本属性的占位记录，如果新增了一项，请在枚举Enu_VisibleExtIndex中补充；
    /// </summary>
    [DefaultValue("")]
    public virtual string VisibleExt { get; set; }

    /// <summary>可选项</summary>
    public int Option { get; set; }

    /// <summary>锁定性</summary>
    public virtual int Locked { get; set; }

    /// <summary>标题</summary>
    public virtual LocaleValue Caption { get; set; }
}

public class K3CloudBuildFilterSQLResponse : SdkResponse<string>
{

}


